package utils
{
	import flash.events.Event;
	import flash.events.IOErrorEvent;
	import flash.net.URLLoader;
	import flash.net.URLRequest;

	public class XMLHelper
	{
		/**
		 * 加载xml 
		 * @param url
		 * 
		 */		
		public static function loadXML(url:String, onLoaded:Function):void
		{
			var loader:URLLoader = new URLLoader();
			loader.addEventListener(Event.COMPLETE, 
				function(event:Event):void
				{
					// xml加载完毕 
					onLoaded(loader.data);
				}
			);
			loader.addEventListener(IOErrorEvent.IO_ERROR, onError);
			loader.load( new URLRequest(url));
		}
		
		protected static function onError(event:IOErrorEvent):void
		{
			trace("file not found!");
		}
		
	}
}